package com.example.chatgpt.controller;

import com.example.chatgpt.Util.R;
import com.example.chatgpt.model.GPTResponse;
import com.example.chatgpt.service.impl.ChartGPTServiceImpl;
import io.micrometer.common.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/chat")
public class ChatGptController {
    @Autowired
    private ChartGPTServiceImpl service;
    @GetMapping
    public ModelAndView index(){
        return new ModelAndView("question");
    }
    @PostMapping
    public R openAiChat(@RequestParam("question")String question){

        if(StringUtils.isBlank(question)){
            return R.fail("请输入问题");
        }
        return R.ok(service.send(question));

    }
}
